public class Test {
    public static void main(String[] args) {
        // 泛型的实例化
        MyArray2<Integer> myArray2 = new MyArray2<>();
        // 这里new之后<>中的类型可以省略，因为编译器可以进行类型推导
        myArray2.setVal(0,10);
        myArray2.setVal(1,12);
        int ret = myArray2.getPos(1);//1
        System.out.println(ret);
        //myArray2.setVal(2,"QAQ");//报错，1处给的是Int型
    }

    public static void main3(String[] args) {
        MyArray myArray = new MyArray();
        myArray.setVal(0,100);
        myArray.setVal(1,"hello");//字符串也可以存放

        //String ret = myArray.getPos(1);//编译报错
        Object ret = myArray.getPos(2);
        //int s = (int) myArray.getPos(3);
        System.out.println(ret);
        //System.out.println(s);
    }

    public static void main2(String[] args) {
        //经典题
        Integer a = 127;
        Integer b = 127;

        Integer c = 128;
        Integer d = 128;

        System.out.println(a==b);//-->true
        System.out.println(c==d);//-->false
        //注意Integer的范围

    }

    public static void main1(String[] args) {
        //包装类
        int i = 10;
       Integer ij = Integer.valueOf(i);//手动装箱
        //Integer ij = new Integer(i);

        int j = ij.intValue();//手动拆箱

        //自动装箱
        Integer ik = i;
        Integer ik2 = (Integer)i;

        //自动拆箱
        int k = ik;
        int k2 = (int)ik2;
    }
}
